package com.nuo.auth.filter.dubbo;

import com.nuo.common.core.constant.TraceLogConstants;
import com.nuo.common.web.util.TraceIdUtil;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @author LGC
 * @date 2022/4/18 10:06
 */
@Activate(group = CommonConstants.PROVIDER)
public class TraceIdProviderFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        String traceId = RpcContext.getContext().getAttachment(TraceLogConstants.TRACE_ID);
        TraceIdUtil.setTraceId(traceId);
        return invoker.invoke(invocation);
    }
}
